/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package interfaz.FrameEncuestas;

import conex.EnqLibConx;
import estructuras.*;
import interfaz.PanelMiembro;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.WindowConstants;

/**
 *
 * @author Shadow
 */
public class FrameLikeIt extends javax.swing.JFrame implements ActionListener{

    private int foo;
    private String strTemp[]=new String[4];
    
    private Survey s;
    private RespEnq re;
    private StructLikeIt strucLikeIt;
    ArrayList <String> datoEnc;
    
    //<editor-fold defaultstate="collapsed" desc="Variables Menu">
    JMenuBar menuBar;
    JMenu menu;
    JMenuItem menuItem;
    JRadioButtonMenuItem rbMILang[];
    
    //</editor-fold>
    
    public FrameLikeIt(int foo,Survey s,RespEnq re,ArrayList<String> datoEnc,StructLikeIt forma) {
        this.foo=foo;
        this.s=s;
        this.re=re;
        this.datoEnc=datoEnc;
        this.strucLikeIt=forma;
        
        setTitle(s.getName());
        
        initComponents();
        menuCharger();
        setIdioma(foo);
        
        setDefaultCloseOperation (WindowConstants.EXIT_ON_CLOSE);
        setLocation(10,20);
        setSize(630, 240);
        setVisible (true);
    }

    public void setIdioma(int foo){
        this.foo=foo;
        strTemp[0]="Pregunta"+s.getActual();strTemp[1]="Question"+s.getActual();strTemp[2]="Frage"+s.getActSize();strTemp[3]="Question"+s.getActSize();
        jlNumAsk.setText(strTemp[foo]);
        jlAsk.setText(strucLikeIt.getQuest(foo));
        strTemp[0]="Totalmente Deacuerdo";strTemp[1]="Strongly Agree";
        strTemp[2]="Trifft Uneingeschränkt Zu";strTemp[3]="Entièrement D'accord";
        jlMostL.setText(strTemp[foo]);
        strTemp[0]="Totalmente en Desacuerdo";strTemp[1]="Strongly Desagree";
        strTemp[2]="Trifft überhaupt nicht zu";strTemp[3]="Fortement en désaccord";
        jlLessL.setText(strTemp[foo]);
        
        strTemp[0]="Siguiente";strTemp[1]="Next";strTemp[2]="Nächste";strTemp[3]="Prochain";
        jButton1.setText(strTemp[foo]);
        
        //idioma en el menu
        strTemp[0]="Idioma";strTemp[1]="Language";strTemp[2]="Sprache";strTemp[3]="langue";
        menu.setText(strTemp[foo]);
        strTemp[0]="Selecciona tu idioma";strTemp[1]="Select your language";strTemp[2]="Wählen Sie Ihre Sprache";strTemp[3]="Choisissez votre langue";
        menuItem.setText(strTemp[foo]);
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        rbGroup = new javax.swing.ButtonGroup();
        jlAsk = new javax.swing.JLabel();
        jlNumAsk = new javax.swing.JLabel();
        jlMostL = new javax.swing.JLabel();
        jrb1 = new javax.swing.JRadioButton();
        jrb2 = new javax.swing.JRadioButton();
        jrb3 = new javax.swing.JRadioButton();
        jrb4 = new javax.swing.JRadioButton();
        jrb5 = new javax.swing.JRadioButton();
        jrb6 = new javax.swing.JRadioButton();
        jrb7 = new javax.swing.JRadioButton();
        jlLessL = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();

        rbGroup.add(jrb1);
        rbGroup.add(jrb2);
        rbGroup.add(jrb3);
        rbGroup.add(jrb4);
        rbGroup.add(jrb5);
        rbGroup.add(jrb6);
        rbGroup.add(jrb7);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jlAsk.setText("jLabel2");

        jlNumAsk.setText("jLabel2");

        jlMostL.setText("jLabel1");

        jrb1.setText("1");

        jrb2.setText("2");

        jrb3.setText("3");

        jrb4.setText("4");

        jrb5.setText("5");

        jrb6.setText("6");
        jrb6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jrb6ActionPerformed(evt);
            }
        });

        jrb7.setText("7");

        jlLessL.setText("jLabel2");

        jButton1.setText("");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(40, 40, 40)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jlNumAsk)
                            .addComponent(jlAsk)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(245, 245, 245)
                                .addComponent(jButton1))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(120, 120, 120)
                                        .addComponent(jrb1)
                                        .addGap(18, 18, 18)
                                        .addComponent(jrb2)
                                        .addGap(18, 18, 18)
                                        .addComponent(jrb3)
                                        .addGap(18, 18, 18)
                                        .addComponent(jrb4)
                                        .addGap(18, 18, 18)
                                        .addComponent(jrb5)
                                        .addGap(18, 18, 18)
                                        .addComponent(jrb6))
                                    .addComponent(jlMostL))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jlLessL)
                                    .addComponent(jrb7))))))
                .addContainerGap(144, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jlNumAsk)
                .addGap(6, 6, 6)
                .addComponent(jlAsk)
                .addGap(18, 18, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jlMostL)
                    .addComponent(jlLessL))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jrb1)
                    .addComponent(jrb2)
                    .addComponent(jrb3)
                    .addComponent(jrb4)
                    .addComponent(jrb5)
                    .addComponent(jrb6)
                    .addComponent(jrb7))
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addGap(20, 20, 20))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jrb6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jrb6ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jrb6ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if(select()){
            re.setRLISI(opSelect(), 1);
            if(!s.islast()){
                switch(s.getNext()){
                    case 0:new FrameAskFree(0,s,re,datoEnc,s.getNextStq());break;
                    case 1:new FrameLikeIt(0,s,re,datoEnc,s.getNextLI());break;
                    case 2:new FrameImaQ(0,s,re,datoEnc,s.getNextStIQ());break;
                    case 3:new FrameMouseTraking(0,s,re,datoEnc,s.getNextQG());
                    default:break;
                }
            }else{
                EnqLibConx eLC=new EnqLibConx();
                eLC.setRes(re, datoEnc, s.getName());
                strTemp[0]="Gracias por Participar";strTemp[1]="Write your Answer";
                strTemp[2]="Schreiben Sie Ihre Antwort";strTemp[3]="Ecrivez votre réponse";
                JOptionPane.showMessageDialog(null,strTemp[foo]);
                new PanelMiembro(foo);
            }
            
            this.dispose();
        }else{
            strTemp[0]="Debes de Seleccionar una Opcion";strTemp[1]="You Must select a choise";
            strTemp[2]="Sie müssen eine Wahl";strTemp[3]="Vous devez sélectionner un choix";
            JOptionPane.showMessageDialog(null,strTemp[foo]);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    public boolean select(){
        boolean b=false;
        if(jrb1.isSelected()){b=true;}
        if(jrb2.isSelected()){b=true;}
        if(jrb3.isSelected()){b=true;}
        if(jrb4.isSelected()){b=true;}
        if(jrb5.isSelected()){b=true;}
        if(jrb6.isSelected()){b=true;}
        if(jrb7.isSelected()){b=true;}
        return b;
    }
    
    public int opSelect(){
        int op=0;
        if(jrb1.isSelected()){op=1;}
        if(jrb2.isSelected()){op=2;}
        if(jrb3.isSelected()){op=3;}
        if(jrb4.isSelected()){op=4;}
        if(jrb5.isSelected()){op=5;}
        if(jrb6.isSelected()){op=6;}
        if(jrb7.isSelected()){op=7;}
        return op;
    }
    
    public void menuCharger(){
    menuBar=new JMenuBar();
    menu = new JMenu();
    strTemp[0]="Idioma";strTemp[1]="Language";strTemp[2]="Sprache";strTemp[3]="langue";
    menu.setText(strTemp[foo]);
    menuBar.add(Box.createHorizontalGlue());
    menuBar.add(menu);
    strTemp[0]="Selecciona tu idioma";strTemp[1]="Select your language";strTemp[2]="Wählen Sie Ihre Sprache";strTemp[3]="Choisissez votre langue";
    menuItem = new JMenuItem(strTemp[foo]);
    menuItem.setEnabled(false);
    menu.add(menuItem);
    menu.addSeparator();
    rbMILang= new JRadioButtonMenuItem[4];
    rbMILang[0]= new JRadioButtonMenuItem("Español");
    rbMILang[1]= new JRadioButtonMenuItem("English");
    rbMILang[2]= new JRadioButtonMenuItem("Deutsh");
    rbMILang[3]= new JRadioButtonMenuItem("Française");
    rbMILang[foo].setSelected(true);
    menu.addSeparator();
    for(int i=0;i<4;i++){
        menu.add(rbMILang[i]);
        rbMILang[i].addActionListener(this);//
    }
    this.setJMenuBar(menuBar);
        //this.add(menuBar);
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jlAsk;
    private javax.swing.JLabel jlLessL;
    private javax.swing.JLabel jlMostL;
    private javax.swing.JLabel jlNumAsk;
    private javax.swing.JRadioButton jrb1;
    private javax.swing.JRadioButton jrb2;
    private javax.swing.JRadioButton jrb3;
    private javax.swing.JRadioButton jrb4;
    private javax.swing.JRadioButton jrb5;
    private javax.swing.JRadioButton jrb6;
    private javax.swing.JRadioButton jrb7;
    private javax.swing.ButtonGroup rbGroup;
    // End of variables declaration//GEN-END:variables

    @Override
    public void actionPerformed(ActionEvent e) {
        for(int i=0;i<4;i++){
            if(e.getSource()==rbMILang[i]){
                for(int j=0;j<4;j++){
                    rbMILang[j].setSelected(false);
                }
                rbMILang[i].setSelected(true);
                setIdioma(i);
            }
        }
    }
}
